home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d20 / yuck_200.arc / YUCK.C < prev    next >
C/C++ Source or Header  |  1990-10-29  |  49KB  |  1,630 lines

  1. #include "yuck.h"                       /* check this file for release notes */
  2. /* ========================================================================= */
  3. tNod *        pts;                     /* pointer to first element in list */
  4. int        maxpt = 0;                          /* next free point entry */
  5. int        lastpolz = -1;            /* last include selected by polz() */
  6. Word        MAXMAP = 0;                      /* current allocated "map"s */
  7. YesNo        inPointnet = No;                  /* flag var for parseRec() */
  8. YesNo        inFd199b = No;                    /* flag var for parseRec() */
  9. tCfg        Cfg;                                 /* configuration record */
  10. Byte *    Cmd[] = { "infile", "oldnet", "nodelist", "unpublished", "zone",
  11.           "kill", "map", "tim_net", "fd199b", "include", "prolog",
  12.           "epilog", "userlist", "sysname", "sysloc", "maxpts",
  13.           "userkill", "userout", "sort", "tempsort", "keeppvt",
  14.           "lfonly", "cronly", "crlf", "clist", "infd199b",
  15.                   "tim_fake", "tim_trim" };
  16. #define    MAXCMD    ( sizeof( Cmd ) / sizeof( Cmd[0] ) )
  17. /* ========================================================================= */
  18. /* Cmnt != 0 strips comments at EOL and trims spaces */
  19. Byte *    getLine( Byte * p, FILE * fp, int Cmnt )
  20. {
  21.     Byte *    q;
  22.  
  23. Loop:    if ( fgets( p, 255, fp ) == NULL ) return NULL;
  24.     assert( p, 255 );
  25.     q = p; skip( q );
  26.     if ( *q == '\n' || *q == ';' || *q == EOS )
  27.         goto Loop;
  28.     q = strchr( p, '\n' );
  29.     if ( q != NULL ) *q = EOS;
  30.     if ( Cmnt == 0 ) return p;
  31.     q = strchr( p, ';' );
  32.     if ( q != NULL ) *q = EOS;
  33.     q = p + strlen( p ) - 1;
  34.     while ( q >= p && ( *q == ' ' || *q == '\t' ) )
  35.         q --;
  36.     *( q + 1 ) = EOS;
  37.     if ( *p == EOS )                                    /* nothing left? */
  38.         goto Loop;                               /* get another line */
  39.     return p;
  40.     }
  41. /* ========================================================================= */
  42. void    parseAd( Byte * p, tAd * a )
  43. {
  44.     Byte *    s, * t, * oldp;
  45.  
  46.     memset( a, EOS, sizeof( tAd ) );
  47.     skip( p );
  48.     oldp = p;
  49.     s = p + strlen( p ) - 1;
  50.     while ( s >= p && ( *s == ' ' || *s == '\t' ) ) s --;
  51.     s[1] = EOS;
  52.     s = strchr( p, ':' );
  53.     if ( s == NULL ) a->z = 0;
  54.     else {
  55.         a->z = (Word) strtol( p, &t, 10 );
  56.         if ( t != s ) {
  57.             printf( "parseAd: bad zone# '%s'\n", oldp );
  58.             exit( 1 );
  59.             }
  60.         p = t + 1;                                 /* point past ':' */
  61.         }
  62.     s = strchr( p, '/' );
  63.     if ( s == NULL ) a->n = 0;
  64.     else {
  65.         a->n = (Word) strtol( p, &t, 10 );
  66.         if ( t != s ) {
  67.             printf( "parseAd: bad net# '%s'\n", oldp );
  68.             exit( 1 );
  69.             }
  70.         p = t + 1;                                 /* point past '/' */
  71.         }
  72.     a->f = (Word) strtol( p, &t, 10 );
  73.     if ( *t == EOS ) return;
  74.     if ( *t != '.' ) {
  75.         printf( "parseAd: junk after node# '%s'\n", oldp );
  76.         exit( 1 );
  77.         }
  78.     t ++;
  79.     a->p = (Word) strtol( t, &s, 10 );
  80.     if ( *s != EOS ) {
  81.         printf( "parseAd: junk after point# '%s'\n", oldp );
  82.         exit( 1 );
  83.         }
  84.     }
  85. /* ========================================================================= */
  86. void    makeName( Byte * p )
  87. {
  88.     Byte *    q, * s;
  89.     int    maxno, r;
  90.     static    Byte    t[80], maxnam[14];
  91. #if    defined( AMIGA )
  92.     struct    FILEINFO *    fb;
  93.  
  94.     if ( ( fb = malloc( sizeof( struct FILEINFO ) ) ) == NULL ) {
  95.         puts( "Out of memory on FILEINFO alloc" );
  96.         exit( 1 );
  97.         }
  98. #else                                                               /* AMIGA */
  99.     static    struct    find_t    fb;
  100. #endif                                                              /* AMIGA */
  101.  
  102.     q = strrchr( p, '/' );
  103.     if ( q == NULL ) q = p;
  104.     q = strchr( q, '.' );
  105.     if ( q != NULL ) return;         /* extension present, don't mess up */
  106.     strcpy( t, p );
  107.     strcat( t, WILDCARD );
  108.     maxno = -1;                                            /* none found */
  109. #if    defined( AMIGA )
  110.     r = dfind( fb, t, 0 );
  111. #else                                                               /* AMIGA */
  112.     r = _dos_findfirst( t, _A_NORMAL | _A_RDONLY |
  113.     _A_HIDDEN | _A_SYSTEM | _A_ARCH, &fb );
  114. #endif                                                              /* AMIGA */
  115. /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  116.     while ( r == 0 ) {
  117.         q = strrchr( FFNAME, '.' );
  118.         if ( q != NULL && strlen( ++ q ) == 3 ) {
  119.             r = (int) strtol( q, &s, 10 );
  120.             if ( s == q + 3 && *s == EOS ) {
  121.                 if ( r > maxno ) {
  122.                     maxno = r;
  123.                     strcpy( maxnam, FFNAME );
  124.                     }
  125.                 }
  126.             }
  127. #if        defined( AMIGA )
  128.         r = dnext( fb );
  129. #else                                                               /* AMIGA */
  130.         r = _dos_findnext( &fb );
  131. #endif                                                              /* AMIGA */
  132.         }
  133.     if ( maxno == -1 ) {
  134.         printf( "makeName: no file qualified '%s'\n", t );
  135.         exit( 1 );
  136.         }
  137.     q = strrchr( maxnam, '.' );
  138.     strcat( p, q );
  139.     }
  140. /* ========================================================================= */
  141. void    makeDir( Byte * p )
  142. {
  143.     strlwr( p );
  144.     for ( ; *p; p ++ )
  145.         if ( *p == '\\' ) *p = '/';
  146.     }
  147. /* ========================================================================= */
  148. void    readCfg( Byte * cfgName )
  149. {
  150.     FILE *    fp;
  151.     Byte *    s, * t, * p;
  152. #if    defined( BIGBUF )
  153.     char *    filbuf;
  154. #endif
  155.     int    i;
  156.     static    Byte    Buf[256], Temp[256];
  157.  
  158.     memset( &Cfg, EOS, sizeof( Cfg ) );
  159.     Cfg.trimJunk = Cfg.putUnpub = Yes;
  160.     Cfg.maxtim = Cfg.maxmap = MAXMAP = 0;             /* no mappings yet */
  161.     strcpy( Cfg.iFile, "pointnet" );
  162.     strcpy( Cfg.oFile, "fdptnet" );
  163.     strcpy( Cfg.nFile, "nodelist" );
  164.     strcpy( Cfg.tFile, SORTTEMP );
  165.     strcpy( Cfg.sysName, POINTNAME );
  166.     strcpy( Cfg.sysLoc, POINTLOC );
  167.     strcpy( Cfg.sysFlags, POINTFLAGS );
  168.     strcpy( Cfg.Sort, SORTCMD );
  169.     strcpy( Cfg.termOldnet, CRLF );
  170.     strcpy( Cfg.termFd199b, CRLF );
  171.     strcpy( Cfg.termClist, CRLF );
  172.     strcpy( Cfg.termUser, CRLF );
  173.     strcpy( Buf, cfgName );
  174.     fp = fopen( cfgName, O_RT );
  175. #if    defined( AMIGA )
  176.     if ( fp == NULL ) {
  177.         strcpy( Buf, MAILDIR );
  178.         strcat( Buf, cfgName );
  179.         fp = fopen( Buf, O_RT );
  180.         }
  181. #endif                                                              /* AMIGA */
  182.     if ( fp == NULL ) {                                   /* this sucks! */
  183.         printf( "readCfg: cfg open failed '%s'\n", Buf );
  184.         exit( 1 );
  185.         }
  186. #if    defined( BIGBUF )
  187.     filbuf = malloc( FBUFSIZ );
  188.     if ( filbuf == NULL )
  189.         printf( "WARNING: no core for file buffer in readCfg()\n" );
  190.     else    setvbuf( fp, filbuf, _IOFBF, FBUFSIZ );
  191. #endif
  192.     while ( getLine( Buf, fp, 1 ) == Buf ) {
  193.         s = Buf;
  194.         skip( s );
  195.         for ( t = Temp; *s && *s != ' ' && *s != '\t'; s ++, t ++ )
  196.             *t = *s;
  197.         *t = EOS;
  198.         skip( s );
  199.         t = s;
  200.         nskip( t );
  201.         for ( i = 0; i < MAXCMD; i ++ )
  202.             if ( stricmp( Cmd[i], Temp ) == 0 )
  203.                 goto Found;
  204.         printf( "readCfg: I/O error '%s'\n", Temp );
  205.         exit( 1 );
  206. Found:        switch ( i ) {                                        /* cmd */
  207. /* infile */
  208. case 0:            if ( strnicmp( s, "-k", 2 ) == 0 ) {
  209.                 Cfg.killInput = Yes;
  210.                 s = t; skip( s );
  211.                 t = s; nskip( t );
  212.                 }
  213.             if ( *t ) {
  214.                 printf( "readCfg: junk 1 at EOL '%s'\n", t );
  215.                 exit ( 1 );
  216.                 }
  217.             strcpy( Cfg.iFile, s );
  218.             Cfg.havePointnet = Yes;
  219.             break;
  220. /* oldnet */
  221. case 1:            Cfg.Oldnet = Yes;
  222.             if ( strnicmp( s, "-a", 2 ) == 0 ) {
  223.                 Cfg.doInclude = Yes;
  224.                 s = t; skip( s );
  225.                 t = s; nskip( t );
  226.                 }
  227.             if ( *t ) {
  228.                 printf( "readCfg: junk 2 at EOL '%s'\n", t );
  229.                 exit ( 1 );
  230.                 }
  231.             strcpy( Cfg.oFile, s );
  232.             break;
  233. /* nodelist */
  234. case 2:            if ( *t ) {
  235.                 printf( "readCfg: junk 3 at EOL '%s'\n", t );
  236.                 exit ( 1 );
  237.                 }
  238.             strcpy( Cfg.nFile, s );
  239.             break;
  240. /* unpublished */
  241. case 3:            if ( *t ) {
  242.                 printf( "readCfg: junk 3a at EOL '%s'\n", t );
  243.                 exit ( 1 );
  244.                 }
  245.             if ( stricmp( s, "yes" ) == 0 )
  246.                 Cfg.putUnpub = Yes;
  247.             else if ( stricmp( s, "no" ) == 0 )
  248.                 Cfg.putUnpub = No;
  249.             else {
  250.                 puts( "readCfg: 'unpublished' requires 'yes' or 'no'." );
  251.                 exit( 1 );
  252.                 }
  253.             break;
  254. /* zone */
  255. case 4:            Cfg.myZone = (Word) strtol( s, &t, 10 );
  256.             if ( t == s || *t != EOS ) {
  257.                 printf( "readCfg: no valid zone# '%s'\n", s );
  258.                 exit( 1 );
  259.                 }
  260.             break;
  261. /* kill */
  262. case 5:            if ( Cfg.maxkill == MAXKILL ) {
  263.                 printf( "readCfg: too many 'kill' nets (max is %u)\n",
  264.                 MAXKILL );
  265.                 exit( 1 );
  266.                 }
  267.             Cfg.killNet[Cfg.maxkill ++] = (Word) strtol( s, &t, 10 );
  268.             if ( t == s || *t != EOS ) {
  269.                 printf( "readCfg: no valid killnet# '%s'\n", s );
  270.                 exit( 1 );
  271.                 }
  272.             break;
  273. /* map */
  274. case 6:            if ( Cfg.maxmap == MAXMAP ) {
  275.                 MAXMAP += MAPINC;        /* increase current */
  276.                 if ( MAXMAP == MAPINC ) {  /* none alloc'ed? */
  277.                     Cfg.mapNet = malloc( (Word) MAXMAP *
  278.                     (Word) sizeof( Word ) );
  279.                     Cfg.mapAd = malloc( (Word) MAXMAP *
  280.                     (Word) sizeof( tAd ) );
  281.                     }
  282.                 else {                      /* must enlarge? */
  283.                     Cfg.mapNet = realloc( Cfg.mapNet,
  284.                     (Word) MAXMAP * (Word) sizeof( Word ) );
  285.                     Cfg.mapAd = realloc( Cfg.mapAd,
  286.                     (Word) MAXMAP * (Word) sizeof( tAd ) );
  287.                     }
  288.                 if ( Cfg.mapNet == NULL || Cfg.mapAd == NULL ) {
  289.                     printf( "readCfg: too many 'map' nets (tried %u)\n",
  290.                     MAXMAP );
  291.                     exit( 1 );
  292.                     }
  293.                 }
  294.             Cfg.mapNet[Cfg.maxmap] = (Word) strtol( s, &t, 10 );
  295.             if ( t == s || ( *t != ' ' && *t != '\t' ) ) {
  296.                 printf( "readCfg: no valid mapnet# or EOL '%s'\n", s );
  297.                 exit( 1 );
  298.                 }
  299.             skip( t );
  300.             s = t; nskip( s );
  301.             if ( *s ) {
  302.                 printf( "readCfg: junk 4 at EOL '%s'\n", t );
  303.                 exit ( 1 );
  304.                 }
  305.             parseAd( t, &Cfg.mapAd[Cfg.maxmap] );
  306.             if ( Cfg.mapAd[Cfg.maxmap].p != 0 ) {
  307.                 printf( "readCfg: no map point# allowed '%s'\n",
  308.                 Buf );
  309.                 exit( 1 );
  310.                 }
  311.             Cfg.maxmap ++;
  312.             break;
  313. /* tim_net */
  314. case 7:            Cfg.fakenet = (Word) strtol( s, &t, 10 );
  315.             if ( t == s || *t != EOS ) {
  316.                 printf( "readCfg: no valid fakenet# '%s'\n", s );
  317.                 exit( 1 );
  318.                 }
  319.             puts( "WARNING: operating in tim_net mode!" );
  320.             Cfg.N109 = Yes;
  321.             break;
  322. /* fd199b */
  323. case 8:            Cfg.Fd199b = Yes;
  324.             if ( *t ) {
  325.                 printf( "readCfg: junk 5 at EOL '%s'\n", t );
  326.                 exit ( 1 );
  327.                 }
  328.             strcpy( Cfg.fFile, s );
  329.             break;
  330. /* include */
  331. case 9:            if ( Cfg.maxinc == MAXINC ) {
  332.                 printf( "readCfg: max includes is %u.\n",
  333.                 MAXINC );
  334.                 exit( 1 );
  335.                 }
  336.             if ( *s == EOS ) {
  337.                 printf( "readCfg: missing parameter '%s'\n",
  338.                 Buf );
  339.                 exit( 1 );
  340.                 }
  341.             Cfg.incNet[Cfg.maxinc].incHdr = No;
  342.             if ( strnicmp( s, "-h", 2 ) == 0 ) {
  343.                 Cfg.incNet[Cfg.maxinc].incHdr = Yes;
  344.                 s = t; skip( s );
  345.                 t = s; nskip( t );
  346.                 }
  347.             t = s; nskip( t );         /* point to first whitespace */
  348.             if ( *t == EOS ) {
  349.                 printf( "readCfg: missing region # '%s'\n", Buf );
  350.                 exit( 1 );
  351.                 }
  352.             *( t ++ ) = EOS;
  353.             if ( stricmp( s, "region" ) == 0 )
  354.                 Cfg.incNet[Cfg.maxinc].Type = Region;
  355.             else if ( stricmp( s, "zone" ) == 0 )
  356.                 Cfg.incNet[Cfg.maxinc].Type = Zone;
  357.             else if ( stricmp( s, "net" ) == 0 )
  358.                 Cfg.incNet[Cfg.maxinc].Type = Host;
  359.             else {
  360.                 printf( "readCfg: invalid include '%s'\n", s );
  361.                 exit( 1 );
  362.                 }
  363.             s = t; skip( s );
  364.             Cfg.incNet[Cfg.maxinc].a.z =
  365.             (Word) strtol( s, &t, 10 );
  366.             if ( Cfg.incNet[Cfg.maxinc].Type == Region ||
  367.                  Cfg.incNet[Cfg.maxinc].Type == Host ) {
  368.                 if ( *t != ':' ) {
  369.                     printf( "readCfg: no valid region# '%s'\n", s );
  370.                     exit( 1 );
  371.                     }
  372.                 t ++;
  373.                 Cfg.incNet[Cfg.maxinc].a.n =
  374.                 (Word) strtol( t, &s, 10 );
  375.                 p = s; s = t; t = p;
  376.                 }
  377.             if ( t == s || *t != EOS ) {
  378.                 printf( "readCfg: no valid include# '%s'\n", s );
  379.                 exit( 1 );
  380.                 }
  381.             Cfg.maxinc ++;
  382.             break;
  383. /* prolog */
  384. case 10:        Cfg.haveProlog = Yes;
  385.             if ( *t ) {
  386.                 printf( "readCfg: junk 8 at EOL '%s'\n", t );
  387.                 exit ( 1 );
  388.                 }
  389.             strcpy( Cfg.pFile, s );
  390.             break;
  391. /* epilog */
  392. case 11:        Cfg.haveEpilog = Yes;
  393.             if ( *t ) {
  394.                 printf( "readCfg: junk 9 at EOL '%s'\n", t );
  395.                 exit ( 1 );
  396.                 }
  397.             strcpy( Cfg.eFile, s );
  398.             break;
  399. /* userlist */
  400. case 12:        if ( strnicmp( s, "-k", 2 ) == 0 ) {
  401.                 Cfg.killUserlist = Yes;
  402.                 s = t; skip( s );
  403.                 t = s; nskip( t );
  404.                 }
  405.             if ( *t ) {
  406.                 printf( "readCfg: junk 91 at EOL '%s'\n", t );
  407.                 exit ( 1 );
  408.                 }
  409.             strcpy( Cfg.uFile, s );
  410.             Cfg.haveUserlist = Yes;
  411.             break;
  412. /* sysname */
  413. case 13:        strncpy( Cfg.sysName, s, 36 );
  414.             Cfg.sysName[36] = EOS;
  415.             break;
  416. /* sysloc */
  417. case 14:        strncpy( Cfg.sysLoc, s, 36 );
  418.             Cfg.sysLoc[36] = EOS;
  419.             break;
  420. /* maxpts */
  421. case 15:        puts( "**  the \"maxpts\" command is obsolete in this and future versions." );
  422.             puts( "**  it will, for the time being, be accepted (but ignored) for" );
  423.             puts( "**  compatibility reasons. please remove the \"maxpts\" command from" );
  424.             puts( "**  your Yuck! control files." );
  425.             break;
  426. /* userkill */
  427. case 16:        if ( Cfg.maxukill == MAXUKILL ) {
  428.                 printf( "readCfg: too many 'userkill' entries (max is %u)\n",
  429.                 MAXUKILL );
  430.                 exit( 1 );
  431.                 }
  432.             parseAd( s, &Cfg.killUser[Cfg.maxukill] );
  433. #if    defined( BREAK_MSC )             /* DO NOT ENABLE -- OPTIMIZER DIES! */
  434.             if ( Cfg.killUser[Cfg.maxukill].p != 0 ) {
  435.                 printf( "readCfg: no userkill point# allowed '%s'\n",
  436.                 Buf );
  437.                 exit( 1 );
  438.                 }
  439. #endif                                   /* DO NOT ENABLE -- OPTIMIZER DIES! */
  440.             Cfg.maxukill ++;
  441.             break;
  442. /* userout */
  443. case 17:        Cfg.haveUserout = Yes;
  444.             if ( strnicmp( s, "-a", 2 ) == 0 ) {
  445.                 Cfg.uoInclude = Yes;
  446.                 s = t; skip( s );
  447.                 t = s; nskip( t );
  448.                 }
  449.             if ( *t ) {
  450.                 printf( "readCfg: junk 22 at EOL '%s'\n", t );
  451.                 exit ( 1 );
  452.                 }
  453.             strcpy( Cfg.lFile, s );
  454.             break;
  455. /* sort */
  456. case 18:        strcpy( Cfg.Sort, s );
  457.             break;
  458. /* tempsort */
  459. case 19:        if ( *t ) {
  460.                 printf( "readCfg: junk 25 at EOL '%s'\n", t );
  461.                 exit ( 1 );
  462.                 }
  463.             strcpy( Cfg.tFile, s );
  464.             break;
  465. /* keeppvt */
  466. case 20:        if ( *t ) {
  467.                 printf( "readCfg: junk 23 at EOL '%s'\n", t );
  468.                 exit ( 1 );
  469.                 }
  470.             if ( stricmp( s, "yes" ) == 0 )
  471.                 Cfg.keepPvt = Yes;
  472.             else if ( stricmp( s, "no" ) == 0 )
  473.                 Cfg.keepPvt = No;
  474.             else {
  475.                 puts( "readCfg: 'keeppvt' requires 'yes' or 'no'." );
  476.                 exit( 1 );
  477.                 }
  478.             break;
  479. /* lfonly */
  480. case 21:
  481. /* cronly */
  482. case 22:
  483. /* crlf */
  484. case 23:        if ( *t ) {
  485.                 printf( "readCfg: junk 39 at EOL '%s'\n", t );
  486.                 exit ( 1 );
  487.                 }
  488.             if ( stricmp( s, "oldnet" ) == 0 )
  489.                 p = Cfg.termOldnet;
  490.             else if ( stricmp( s, "fd199b" ) == 0 )
  491.                 p = Cfg.termFd199b;
  492.             else if ( stricmp( s, "userout" ) == 0 )
  493.                 p = Cfg.termUser;
  494.             else if ( stricmp( s, "clist" ) == 0 )
  495.                 p = Cfg.termClist;
  496.             else {
  497.                 printf( "%s is not a valid parameter to %s.\n",
  498.                 s, Temp );
  499.                 exit( 1 );
  500.                 }
  501.             strcpy( p, i == 21? LF: ( i == 22? CR: CRLF ) );
  502.             break;
  503. /* clist */
  504. case 24:        Cfg.Clist = Yes;
  505.             if ( *t ) {
  506.                 printf( "readCfg: junk 5 at EOL '%s'\n", t );
  507.                 exit ( 1 );
  508.                 }
  509.             strcpy( Cfg.cFile, s );
  510.             break;
  511. /* infd199b */
  512. case 25:        if ( strnicmp( s, "-k", 2 ) == 0 ) {
  513.                 Cfg.killInfd199b = Yes;
  514.                 s = t; skip( s );
  515.                 t = s; nskip( t );
  516.                 }
  517.             if ( *t ) {
  518.                 printf( "readCfg: junk 81 at EOL '%s'\n", t );
  519.                 exit ( 1 );
  520.                 }
  521.             strcpy( Cfg.bFile, s );
  522.             Cfg.haveInfd199b = Yes;
  523.             break;
  524. /* tim_fake */
  525. case 26:        if ( Cfg.maxtim == MAXTIM ) {
  526.                 printf( "readCfg: too many 'tim_fake' nets (max is %u)\n",
  527.                 MAXTIM );
  528.                 exit( 1 );
  529.                 }
  530.             Cfg.timfake[Cfg.maxtim ++] = (Word) strtol( s, &t, 10 );
  531.             if ( t == s || *t != EOS ) {
  532.                 printf( "readCfg: no valid tim_fake# '%s'\n", s );
  533.                 exit( 1 );
  534.                 }
  535.             break;
  536. /* tim_trim */
  537. case 27:        if ( *t ) {
  538.                 printf( "readCfg: junk 27a at EOL '%s'\n", t );
  539.                 exit ( 1 );
  540.                 }
  541.             if ( stricmp( s, "yes" ) == 0 )
  542.                 Cfg.trimJunk = Yes;
  543.             else if ( stricmp( s, "no" ) == 0 )
  544.                 Cfg.trimJunk = No;
  545.             else {
  546.                 puts( "readCfg: 'tim_trim' requires 'yes' or 'no'." );
  547.                 exit( 1 );
  548.                 }
  549.             break;
  550. default:        printf( "readCfg: switch fucked up %04xh\n", i );
  551.             exit( 1 );
  552.             }                                             /* cmd */
  553.         }
  554. /* ------------------------------------------------------------------------- */
  555.     fclose( fp );
  556. #if    defined( BIGBUF )
  557.     if ( filbuf != NULL )
  558.         free( filbuf );
  559.     filbuf = NULL;
  560. #endif
  561.     for ( s = Cfg.sysName; *s; s ++ )
  562.         if ( *s == ' ' || *s == '\t' )
  563.             *s = '_';
  564.     for ( s = Cfg.sysLoc; *s; s ++ )
  565.         if ( *s == ' ' || *s == '\t' )
  566.             *s = '_';
  567.     if ( *Cfg.sysName != EOS )  /* do not use sysop name as system name? */
  568.         Cfg.haveSysname = Yes;
  569. /* ------------------------------------------------------------------------- */
  570.     makeDir( Cfg.iFile );
  571.     makeDir( Cfg.bFile );
  572.     makeDir( Cfg.uFile );
  573.     makeDir( Cfg.oFile );
  574.     makeDir( Cfg.fFile );
  575.     makeDir( Cfg.cFile );
  576.     makeDir( Cfg.lFile );
  577.     makeDir( Cfg.nFile );
  578.     makeDir( Cfg.pFile );
  579.     makeDir( Cfg.eFile );
  580.     makeDir( Cfg.tFile );
  581.     makeName( Cfg.nFile );
  582.     if ( Cfg.havePointnet == Yes )
  583.         makeName( Cfg.iFile );
  584.     if ( Cfg.haveInfd199b == Yes )
  585.         makeName( Cfg.bFile );
  586.     if ( Cfg.haveUserlist == Yes )
  587.         makeName( Cfg.uFile );
  588.     if ( Cfg.havePointnet )
  589.         p = Cfg.iFile;
  590.     else if ( Cfg.haveInfd199b )
  591.         p = Cfg.bFile;
  592.     else if ( Cfg.haveUserlist )
  593.         p = Cfg.uFile;
  594.     else {
  595.         puts( "Wozzat? no input file? ABORTED!" );
  596.         exit( 1 );
  597.         }
  598.     s = strrchr( Cfg.tFile, '/' );
  599.     if ( s == NULL ) s = Cfg.tFile;
  600.     t = strchr( s, '.' );
  601.     if ( t == NULL ) strcat( Cfg.tFile, strrchr( p, '.' ) );
  602.     s = strrchr( Cfg.oFile, '/' );
  603.     if ( s == NULL ) s = Cfg.oFile;
  604.     t = strchr( s, '.' );
  605.  
  606.     s = strrchr( Cfg.lFile, '/' );
  607.     if ( s == NULL ) s = Cfg.lFile;
  608.     t = strchr( s, '.' );
  609.     if ( t == NULL ) strcat( Cfg.lFile, strrchr( p, '.' ) );
  610.     s = strrchr( Cfg.fFile, '/' );
  611.     if ( s == NULL ) s = Cfg.fFile;
  612.     t = strchr( s, '.' );
  613.     if ( t == NULL ) strcat( Cfg.fFile, strrchr( p, '.' ) );
  614.     s = strrchr( Cfg.cFile, '/' );
  615.     if ( s == NULL ) s = Cfg.cFile;
  616.     t = strchr( s, '.' );
  617.     if ( t == NULL ) strcat( Cfg.cFile, strrchr( p, '.' ) );
  618.     }
  619. /* ========================================================================= */
  620. void    dumpRec( tNod * b, FILE * o, int nl )
  621. {
  622.     Byte *    p;
  623.     static    Byte    Temp[50], oBuf[256];
  624.  
  625.     p = &oBuf[0];
  626.     sprintf( Temp, "%u:%u", b->a.z, b->a.n );
  627.     p = oBuf + sprintf( oBuf, "\r%-6.6s %9s/", aTyp[(int) b->Type], Temp );
  628.     sprintf( Temp, "%u.%u", b->a.f, b->a.p );
  629.     sprintf( p, "%-10s %5u %-40.40s %-40.40s %-40.40s %-40.40s %5u %-40.40s",
  630.     Temp, b->No, b->Bbs, b->City, b->Sysop, b->Tel, b->Baud, b->Flags );
  631.     assert( oBuf, 255 );
  632.     if ( o == NULL ) {
  633.         oBuf[79] = EOS;
  634.         if ( nl ) puts( oBuf );
  635.         else fputs( oBuf, stdout );
  636.         }
  637.     else {
  638.         fputs( oBuf, o );
  639.         if ( nl ) putc( '\n', o );
  640.         }
  641.     }
  642. /* ========================================================================= */
  643. int    find( Word ln, Word * p, int n )
  644. {
  645.     Word *    q = p;
  646.  
  647.     for ( ; n; n --, p ++ )
  648.         if ( ln == *p ) return p - q;
  649.     return -1;
  650.     }
  651. /* ========================================================================= */
  652. void    killNets( void )
  653. {
  654.     tNod *    p;
  655.     Word    ln;
  656.     int    state;
  657.     tAd    null;
  658.  
  659.     null.z = null.n = null.f = null.p = 0;
  660.     state = 0; ln = 0xffff;
  661.     for ( p = pts; p != NULL; p = p->nx ) {
  662.         switch ( state ) {
  663. case 0:            if ( ln == p->a.n )
  664.                 break;
  665.             ln = p->a.n;
  666.             if ( find( ln, Cfg.killNet, Cfg.maxkill ) != -1 ) {
  667.                 state = 1;            /* set state to "kill" */
  668.                 p->a = null;
  669.                 }
  670.             break;
  671. case 1:            if ( ln == p->a.n ) {
  672.                 p->a = null;
  673.                 break;
  674.                 }
  675.             ln = p->a.n;
  676.             if ( find( ln, Cfg.killNet, Cfg.maxkill ) == -1 ) {
  677.                 state = 0;          /* set state to "nokill" */
  678.                 }
  679.             break;
  680. default:        printf( "killNets: illegal state %04xh\n", state );
  681.             exit( 1 );
  682.             }
  683.         }
  684.     }
  685. /* ========================================================================= */
  686. int    get109( Byte * str, Word * net, Word * nod )    /* parse Jasionowski */
  687. {
  688.     Byte *    s, * t;
  689.     Word    temp;
  690.     Byte    tStr[20];
  691.  
  692.     s = strrchr( str, N109FCHR );
  693.     if ( s == NULL ) goto noNet;
  694.     sprintf( tStr, "%c%%u%c%%u", N109FCHR, N109CHR );
  695.     if ( 2 != sscanf( s, tStr, net, nod ) ) goto noNet;
  696.     if ( Cfg.trimJunk == Yes ) *s = EOS;
  697.     return 1;
  698.  
  699. noNet:    s = strrchr( str, N109CHR );
  700.     if ( s == NULL )
  701.         return 0;
  702.     s ++;
  703.     temp = (Word) strtol( s, &t, 10 );
  704.     if ( *t == EOS && t > s ) {
  705.         *net = Cfg.fakenet, *nod = temp;                                  /* valid boss# */
  706.         if ( Cfg.trimJunk == Yes ) *( s - 1 ) = EOS;
  707.         return 1;
  708.         }
  709.     return 0;
  710.     }
  711. /* ========================================================================= */
  712. void    mapNets( void )
  713. {
  714.     Word    ln, temp;
  715.     int    findres;
  716.     tAd    la;
  717.     tNod *    p;
  718.  
  719.     ln = 0xffff;
  720.     for ( p = pts; p != NULL; p = p->nx ) {
  721. doit:        if ( p->a.n == ln ) {
  722.             temp = p->a.f;
  723.             p->a = la;
  724.             p->a.p = temp;
  725.             p->Type = Point;
  726.             if ( Cfg.N109 == Yes ) {
  727.                 Word tnet, tnod;
  728.                 tnet = tnod = 0;
  729.                 if ( 0 == get109( p->Bbs, &tnet, &tnod ) )
  730.                     continue;
  731.                 if ( tnet != 0 )
  732.                     p->a.n = tnet;
  733.                 p->a.f = tnod;
  734.                 }
  735.             continue;
  736.             }
  737.         ln = p->a.n;
  738.         findres = find( ln, Cfg.mapNet, Cfg.maxmap );
  739.         if ( findres == -1 && ln != 0 ) {
  740.             findres = find( ln, Cfg.timfake, Cfg.maxtim );
  741.             if ( findres == -1 && ln != 0 ) {
  742.                 printf( "Killing unmapped net %u\n", ln );
  743.                 la.z = la.n = la.f = la.p = 0;
  744.                 }
  745.             }
  746.         else    la = Cfg.mapAd[findres];
  747.         goto doit;
  748.         }
  749.     }
  750. /* ========================================================================= */
  751. void    removeNets( void )
  752. {
  753.     tNod *    p;
  754.     tNod *    q;
  755.  
  756.     p = pts;
  757.     while ( p != NULL ) {
  758.         if ( p->a.n == 0 ) {
  759.             q = p;
  760.             p = p->nx;
  761.             delNod( q );
  762.             maxpt --;
  763.             }
  764.         else    p = p->nx;
  765.         }
  766.     }
  767. /* ========================================================================= */
  768. void    dumpList( void )
  769. {
  770.     tNod *    p;
  771.  
  772.     for ( p = pts; p != NULL; p = p->nx )
  773.         dumpRec( p, NULL, 1 );
  774.     putchar( '\n' );
  775.     }
  776. /* ========================================================================= */
  777. int    needed( tAd a )
  778. {
  779.     tNod *    p;
  780.  
  781.     for ( p = pts; p != NULL; p = p->nx ) {
  782.         if ( p->a.z == a.z && p->a.n == a.n && p->a.f == a.f )
  783.             return 1;
  784.         }
  785.     return 0;
  786.     }
  787. /* ========================================================================= */
  788. void    wrtRec( tNod * p, FILE * of, YesNo Fd199b, Byte * Term )
  789. {
  790.     Word    n;
  791.     Byte *    typeStr;
  792.  
  793.     typeStr = aTyp[(int) p->Type];
  794.     switch ( p->Type ) {
  795. case Zone:    n = p->a.z; fprintf( of, ";%s", Term ); break;
  796. case Region:
  797. case Host:    n = p->a.n; fprintf( of, ";%s", Term ); break;
  798. case Point:    n = p->a.p;
  799.         if ( Cfg.putUnpub == Yes )
  800.             strcpy( p->Tel, "-Unpublished-" );
  801.         if ( Fd199b == Yes )
  802.             typeStr = "";
  803.         break;
  804. default:    n = p->a.f; break;
  805.         }
  806.     fprintf( of, "%s,%u,%s,%s,%s,%s,%u,%s%s", typeStr, n,
  807.     p->Bbs, p->City, p->Sysop, p->Tel, p->Baud, p->Flags, Term );
  808. /* ***    dumpRec( p, NULL, 1 ); */
  809.     }
  810. /* ========================================================================= */
  811. /* Type == Point is a special case: a contains a Zone entry's address. polz  */
  812. /* should return 1 if any regions from that zone are to be included. this is */
  813. /* used to determine whether a Zone entry should be written without the copy */
  814. /* mode being set to 1 (copy entire zone).                                   */
  815. /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  816. int    polz( eTyp Type, tAd a )
  817. {
  818.     int    i;
  819.  
  820.     if ( Type == Point ) {
  821.         for ( i = 0; i < Cfg.maxinc; i ++ )
  822.             if ( ( Region == Cfg.incNet[i].Type ||
  823.                  Host == Cfg.incNet[i].Type ) &&
  824.                  a.z == Cfg.incNet[i].a.z ) {
  825.                 lastpolz = i;
  826.                 return 1;
  827.                 }
  828.         return 0;
  829.         }
  830.     else if ( Type == Host ) {
  831.         for ( i = 0; i < Cfg.maxinc; i ++ )
  832.             if ( Type == Cfg.incNet[i].Type &&
  833.             a.n == Cfg.incNet[i].a.n && a.z == Cfg.incNet[i].a.z ) {
  834.                 lastpolz = i;
  835.                 return 1;
  836.                 }
  837.         return 0;
  838.         }
  839.     else if ( Type == Region ) {
  840.         for ( i = 0; i < Cfg.maxinc; i ++ )
  841.             if ( Type == Cfg.incNet[i].Type &&
  842.             a.n == Cfg.incNet[i].a.n && a.z == Cfg.incNet[i].a.z ) {
  843.                 lastpolz = i;
  844.                 return 1;
  845.                 }
  846.         return 0;
  847.         }
  848.     else if ( Type == Zone ) {
  849.         for ( i = 0; i < Cfg.maxinc; i ++ )
  850.             if ( Type == Cfg.incNet[i].Type &&
  851.                   a.z == Cfg.incNet[i].a.z ) {
  852.                 lastpolz = i;
  853.                 return 1;
  854.                 }
  855.         return 0;
  856.         }
  857.     else {
  858.         puts( "polz(): i'm sorry, dave, but i can't do that." );
  859.         exit( 50 );
  860.         }
  861.     }
  862. /* ========================================================================= */
  863. void    wrtList( FILE * fp, FILE * of )
  864. {
  865.     int    ptsleft, isNeeded = 0;
  866.     tNod *    p;
  867.     tNod    last, lz, ln;
  868.     static    tNod    Nod;
  869.     static    Byte    Buf[256];
  870.  
  871.     lastpolz = -1;                         /* make sure it is intialized */
  872.     memset( &Nod, EOS, sizeof( Nod ) );
  873.     last.Type = Point;
  874.     last.a.z = last.a.n = last.a.f = last.a.p = -1;       /* force write */
  875.     ptsleft = maxpt;
  876.     parseRec( NULL, NULL, 1 );         /* reset parseRec() state machine */
  877.     while ( ( Cfg.doInclude || ptsleft != 0 ) &&
  878.             getLine( Buf, fp, 0 ) == Buf ) {
  879.         parseRec( Buf, &Nod, 0 );
  880. /* ***        dumpRec( &Nod, NULL, 1 ); */
  881. /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  882.         if ( Cfg.doInclude == Yes ) {
  883.             if ( Nod.Type == Region ) {
  884.                 printf( "\rScanning %u:%u ... ", Nod.a.z, Nod.a.n );
  885.                 fflush( stdout );
  886.                 }
  887. /* this resets the include state var in case only the header of a nodelist */
  888. /* part is desired. */
  889.             if ( isNeeded != 0 && lastpolz != -1 &&
  890.                  Cfg.incNet[lastpolz].incHdr == Yes &&
  891.                  ( Nod.Type == Zone || Nod.Type == Region ||
  892.                    Nod.Type == Host || Nod.Type == Hub ) )
  893.                 isNeeded = 0;
  894. /* the following logic decides whether to go into include-mode. isNeeded is */
  895. /* the state variable, polz() determines whether it should be set. lower */
  896. /* values (except 0) override higher ones in isNeeded, ensuring that the */
  897. /* largest of any overlapping includes will be selected. */
  898.             if ( Nod.Type == Zone ) {
  899.                 isNeeded = 0;
  900.                 if ( polz( Zone, Nod.a ) )
  901.                     isNeeded = 1;
  902.                 if ( isNeeded != 1 && polz( Point, Nod.a ) ) {
  903.                     wrtRec( &Nod, of, No, Cfg.termOldnet );
  904.                     last = lz = Nod;
  905.                     }
  906.                 }
  907.             if ( isNeeded != 1 && Nod.Type == Region ) {
  908.                 isNeeded = 0;
  909.                 if ( polz( Region, Nod.a ) )
  910.                     isNeeded = 2;
  911.                 }
  912.             if ( isNeeded != 1 && isNeeded != 2 &&
  913.                  Nod.Type == Host ) {
  914.                 isNeeded = 0;
  915.                 if ( polz( Host, Nod.a ) )
  916.                     isNeeded = 3;
  917.                 }
  918.             if ( isNeeded ) {
  919.                 wrtRec( &Nod, of, No, Cfg.termOldnet );
  920.                 last = Nod;
  921.                 }
  922.             }
  923. /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  924.         switch ( Nod.Type ) {
  925. case Zone:        lz = Nod; continue;             /* just file it away */
  926. case Region:        printf( "\rScanning %u:%u ... ", Nod.a.z, Nod.a.n );
  927.             fflush( stdout );
  928. case Host:        ln = Nod;                       /* just file it away */
  929. case Hub:
  930. case Pvt:
  931. case Hold:
  932. case Down:
  933. case Node:        if ( ! needed( Nod.a ) )
  934.                 continue;          /* no points for that one */
  935.             if ( last.a.z != Nod.a.z ) {            /* new zone? */
  936.                 wrtRec( &lz, of, No, Cfg.termOldnet );
  937.                 last = lz;           /* set new last-written */
  938.                 }                               /* new zone? */
  939.             if ( last.a.n != Nod.a.n ) {             /* new net? */
  940.                 wrtRec( &ln, of, No, Cfg.termOldnet );
  941.                 last = ln;           /* set new last-written */
  942.                 }                                /* new net? */
  943.             if ( last.a.z != Nod.a.z || last.a.n != Nod.a.n ||
  944.                  last.a.f != Nod.a.f )
  945.                 wrtRec( &Nod, of, No, Cfg.termOldnet );
  946.             last = Nod;                  /* set new last-written */
  947.             break;                   /* fall thru to point-check */
  948. default:        continue;                               /* next node */
  949.             }
  950. /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  951.         for ( p = pts; p != NULL; p = p->nx ) {
  952.             if ( p->a.z == Nod.a.z && p->a.n == Nod.a.n &&
  953.             p->a.f == Nod.a.f ) {
  954.                 wrtRec( p, of, No, Cfg.termOldnet );
  955.                 p->prcd = Yes;
  956.                 ptsleft --;
  957.                 }                    /* if pts[i].a == Nod.a */
  958.             }                              /* for i (all points) */
  959.         }                            /* while nodelist not exhausted */
  960.     fputs( "\r                        \r", stdout );
  961.     }
  962. /* ========================================================================= */
  963. int    ptCmp( tNod ** p, tNod ** q )
  964. {
  965.     tNod *    pp;
  966.     tNod *    qq;
  967.  
  968.     pp = *p;
  969.     qq = *q;
  970.     if (  pp->a.z < qq->a.z ) return -1;
  971.     if (  pp->a.z > qq->a.z ) return  1;
  972.     if (  pp->a.n < qq->a.n ) return -1;
  973.     if (  pp->a.n > qq->a.n ) return  1;
  974.     if (  pp->a.f < qq->a.f ) return -1;
  975.     if (  pp->a.f > qq->a.f ) return  1;
  976.     if (  pp->a.p < qq->a.p ) return -1;
  977.     if (  pp->a.p > qq->a.p ) return  1;
  978.     return 0;
  979.     }
  980. /* ========================================================================= */
  981. void    wrtClist( FILE * of )
  982. {
  983.     tNod *    p;
  984.     tAd    lastw;
  985.  
  986.     lastw.z = lastw.n = lastw.f = lastw.p = 0xffff;        /* force boss */
  987.     for ( p = pts; p != NULL; p = p->nx ) {
  988.         if ( lastw.z != p->a.z ) {
  989.             fprintf( of, ";%sZone,%u,->%s",
  990.             Cfg.termClist, p->a.z, Cfg.termClist );
  991.             lastw.z = lastw.n = p->a.z;
  992.             lastw.f = lastw.p = 0;
  993.             }
  994.         if ( lastw.n != p->a.n ) {
  995.             fprintf( of, ";%sHost,%u,->%s",
  996.             Cfg.termClist, p->a.n, Cfg.termClist );
  997.             lastw.n = p->a.n;
  998.             lastw.f = lastw.p = 0;
  999.             }
  1000.         if ( lastw.f != p->a.f ) {
  1001.             fprintf( of, ",%u,->%s", p->a.f, Cfg.termClist );
  1002.             lastw.f = p->a.f;
  1003.             lastw.p = 0;
  1004.             }
  1005.         wrtRec( p, of, No, Cfg.termClist );
  1006.         p->prcd = Yes;
  1007.         }
  1008.     }
  1009. /* ========================================================================= */
  1010. void    wrt199bList( FILE * of )
  1011. {
  1012.     tNod *    p;
  1013.     tAd    lastw;
  1014.  
  1015.     lastw.z = lastw.n = lastw.f = lastw.p = 0xffff;        /* force boss */
  1016.     for ( p = pts; p != NULL; p = p->nx ) {
  1017.         if ( lastw.z != p->a.z || lastw.n != p->a.n ||
  1018.              lastw.f != p->a.f ) {
  1019.             lastw = p->a;
  1020.             lastw.p = 0;
  1021.             fprintf( of, ";%sBoss,%u:%u/%u%s", Cfg.termFd199b,
  1022.             lastw.z, lastw.n, lastw.f, Cfg.termFd199b );
  1023.             }
  1024.         wrtRec( p, of, Yes, Cfg.termFd199b );
  1025.         p->prcd = Yes;
  1026.         }
  1027.     }
  1028. /* ========================================================================= */
  1029. void    readPointnet( void )
  1030. {
  1031.     FILE *    fp;
  1032. #if    defined( BIGBUF )
  1033.     char *    filbuf;
  1034. #endif
  1035.     static    tNod    Nod;
  1036.     static    Byte    Buf[256];
  1037.  
  1038.     fp = fopen( Cfg.iFile, O_RT );
  1039.     if ( fp == NULL ) {
  1040.         printf( "Can't open %s\n", Cfg.iFile );
  1041.         exit( 2 );
  1042.         }
  1043. #if    defined( BIGBUF )
  1044.     filbuf = malloc( FBUFSIZ );
  1045.     if ( filbuf == NULL )
  1046.         printf( "WARNING: no core for file buffer in readCfg()\n" );
  1047.     else    setvbuf( fp, filbuf, _IOFBF, FBUFSIZ );
  1048. #endif
  1049.     inPointnet = Yes;                /* notify parseRec() re. pvt points */
  1050.     parseRec( NULL, NULL, 1 );         /* reset parseRec() state machine */
  1051.     while ( getLine( Buf, fp, 0 ) == Buf ) {
  1052.         parseRec( Buf, &Nod, 0 );
  1053.         if ( Nod.Type != Node )
  1054.             continue;
  1055.         addNod( 1, &Nod );
  1056.         maxpt ++;
  1057.         }
  1058.     inPointnet = No;                    /* reset parseRec() to kill Pvts */
  1059.     fclose( fp );
  1060. #if    defined( BIGBUF )
  1061.     if ( filbuf != NULL )
  1062.         free( filbuf );
  1063.     filbuf = NULL;
  1064. #endif
  1065.     }
  1066. /* ========================================================================= */
  1067. void    readUserlist( void )
  1068. {
  1069.     FILE *    fp;
  1070.     int    i;
  1071.     Byte *    p;
  1072. #if    defined( BIGBUF )
  1073.     char *    filbuf;
  1074. #endif
  1075.     static    tNod    Nod;
  1076.     static    Byte    Buf[256];
  1077.  
  1078.     fp = fopen( Cfg.uFile, O_RT );
  1079.     if ( fp == NULL ) {
  1080.         printf( "Can't open %s\n", Cfg.uFile );
  1081.         exit( 2 );
  1082.         }
  1083. #if    defined( BIGBUF )
  1084.     filbuf = malloc( FBUFSIZ );
  1085.     if ( filbuf == NULL )
  1086.         printf( "WARNING: no core for file buffer in readCfg()\n" );
  1087.     else    setvbuf( fp, filbuf, _IOFBF, FBUFSIZ );
  1088. #endif
  1089.     strncpy( Nod.Bbs, Cfg.sysName, sizeof( Nod.Bbs ) - 1 );
  1090.     Nod.Bbs[sizeof( Nod.Bbs ) - 1] = EOS;
  1091.     strncpy( Nod.City, Cfg.sysLoc, sizeof( Nod.City ) - 1 );
  1092.     Nod.City[sizeof( Nod.City ) - 1] = EOS;
  1093.     strncpy( Nod.Flags, POINTFLAGS, sizeof( Nod.Flags ) - 1 );
  1094.     Nod.Flags[sizeof( Nod.Flags ) - 1] = EOS;
  1095.     strcpy( Nod.Tel, "-Unpublished-" );
  1096.     Nod.Baud = POINTBAUD;
  1097.     Nod.Type = Point;
  1098.     while ( getLine( Buf, fp, 0 ) == Buf ) {
  1099.         parseAd( Buf + POINTADDR, &Nod.a );
  1100.         if ( Nod.a.p == 0 )
  1101.             continue;
  1102.         if ( Nod.a.z == 0 ) Nod.a.z = Cfg.myZone;
  1103.         for ( i = 0; i < Cfg.maxukill; i ++ )
  1104.             if ( Cfg.killUser[i].z == Nod.a.z &&
  1105.                  Cfg.killUser[i].n == Nod.a.n &&
  1106.                  Cfg.killUser[i].f == Nod.a.f )
  1107.                 goto Ignore;
  1108.         memset( Nod.Sysop, EOS, sizeof( Nod.Sysop ) );
  1109.         p = Buf + POINTADDR;
  1110.         while ( p >= Buf && *p == ' ' ) p --;
  1111.         p[1] = EOS;
  1112.         p = strchr( Buf, ',' );
  1113.         if ( p != NULL ) {
  1114.             *( p ++ ) = EOS;
  1115.             skip( p );
  1116.             strcpy( Nod.Sysop, p );
  1117.             p = Nod.Sysop + strlen( Nod.Sysop );
  1118.             if ( p > Nod.Sysop ) {
  1119.                 *p = ' ';
  1120.                 p[1] = EOS;
  1121.                 }
  1122.             }
  1123.         strcat( Nod.Sysop, Buf );
  1124.         for ( p = Nod.Sysop; *p; p ++ )
  1125.             if ( *p == ' ' || *p == '\t' )
  1126.                 *p = '_';
  1127.         if ( Cfg.haveSysname == No )              /* use sysop name? */
  1128.             memcpy( Nod.Bbs, Nod.Sysop, sizeof( Nod.Sysop ) );
  1129.         Nod.No = Nod.a.p;
  1130.         addNod( 1, &Nod );
  1131.         maxpt ++;
  1132. Ignore:        ;
  1133.         }
  1134.     fclose( fp );
  1135. #if    defined( BIGBUF )
  1136.     if ( filbuf != NULL )
  1137.         free( filbuf );
  1138.     filbuf = NULL;
  1139. #endif
  1140.     }
  1141. /* ========================================================================= */
  1142. void    wrtuRec( tNod * p, FILE * of )
  1143. {
  1144.     Byte *    q, t0[40], t1[20], t2[20];
  1145.  
  1146.     sprintf( t1, "%u:%u", p->a.z, p->a.n );
  1147.     sprintf( t2, p->a.p != 0? "%u.%u": "%u", p->a.f, p->a.p );
  1148.     q = strrchr( p->Sysop, '_' );
  1149.     if ( q == NULL ) strcpy( t0, p->Sysop );
  1150.     else {
  1151.         strcpy( t0, q + 1 );
  1152.         strcat( t0, ", " );
  1153.         *q = EOS;
  1154.         strcat( t0, p->Sysop );
  1155.         *q = '_';
  1156.         }
  1157.     for ( q = strchr( t0, '_' ); q != NULL; q = strchr( q, '_' ) )
  1158.         *q = ' ';
  1159.     fprintf( of, "%-40s %14.14s/%-14.14s%s", t0, t1, t2, Cfg.termUser );
  1160. /* ***    dumpRec( p, NULL, 1 ); */
  1161.     }
  1162. /* ========================================================================= */
  1163. void    wrtuList( FILE * fp, FILE * of )
  1164. {
  1165.     int    ptsleft, isNeeded = 0;
  1166.     tNod *    p;
  1167.     tNod    last, lz, ln;
  1168.     static    tNod    Nod;
  1169.     static    Byte    Buf[256];
  1170.  
  1171.     lastpolz = -1;                         /* make sure it is intialized */
  1172.     memset( &Nod, EOS, sizeof( Nod ) );
  1173.     last.Type = Point;
  1174.     last.a.z = last.a.n = last.a.f = last.a.p = -1;       /* force write */
  1175.     ptsleft = maxpt;
  1176.     parseRec( NULL, NULL, 1 );         /* reset parseRec() state machine */
  1177.     while ( ( Cfg.uoInclude || ptsleft != 0 ) &&
  1178.             getLine( Buf, fp, 0 ) == Buf ) {
  1179.         parseRec( Buf, &Nod, 0 );
  1180. /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  1181.         if ( Cfg.uoInclude == Yes ) {
  1182.             if ( Nod.Type == Region ) {
  1183.                 printf( "\rScanning %u:%u ... ", Nod.a.z, Nod.a.n );
  1184.                 fflush( stdout );
  1185.                 }
  1186. /* this resets the include state var in case only the header of a nodelist */
  1187. /* part is desired. */
  1188.             if ( isNeeded != 0 && lastpolz != -1 &&
  1189.                  Cfg.incNet[lastpolz].incHdr == Yes &&
  1190.                  ( Nod.Type == Zone || Nod.Type == Region ||
  1191.                    Nod.Type == Host || Nod.Type == Hub ) )
  1192.                 isNeeded = 0;
  1193. /* the following logic decides whether to go into include-mode. isNeeded is */
  1194. /* the state variable, polz() determines whether it should be set. lower */
  1195. /* values (except 0) override higher ones in isNeeded, ensuring that the */
  1196. /* largest of any overlapping includes will be selected. */
  1197.             if ( Nod.Type == Zone ) {
  1198.                 isNeeded = 0;
  1199.                 if ( polz( Zone, Nod.a ) )
  1200.                     isNeeded = 1;
  1201.                 if ( isNeeded != 1 && polz( Point, Nod.a ) ) {
  1202.                     wrtuRec( &Nod, of );
  1203.                     last = lz = Nod;
  1204.                     }
  1205.                 }
  1206.             if ( isNeeded != 1 && Nod.Type == Region ) {
  1207.                 isNeeded = 0;
  1208.                 if ( polz( Region, Nod.a ) )
  1209.                     isNeeded = 2;
  1210.                 }
  1211.             if ( isNeeded != 1 && isNeeded != 2 &&
  1212.                  Nod.Type == Host ) {
  1213.                 isNeeded = 0;
  1214.                 if ( polz( Host, Nod.a ) )
  1215.                     isNeeded = 3;
  1216.                 }
  1217.             if ( isNeeded ) {
  1218.                 wrtuRec( &Nod, of );
  1219.                 last = Nod;
  1220.                 }
  1221.             }
  1222. /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  1223.         switch ( Nod.Type ) {
  1224. case Zone:        lz = Nod; continue;             /* just file it away */
  1225. case Region:        printf( "\rScanning %u:%u ... ", Nod.a.z, Nod.a.n );
  1226.             fflush( stdout );
  1227. case Host:        ln = Nod;                       /* just file it away */
  1228. case Hub:
  1229. case Node:        if ( ! needed( Nod.a ) )
  1230.                 continue;          /* no points for that one */
  1231.             if ( last.a.z != Nod.a.z ) {            /* new zone? */
  1232.                 wrtuRec( &lz, of );
  1233.                 last = lz;           /* set new last-written */
  1234.                 }                               /* new zone? */
  1235.             if ( last.a.n != Nod.a.n ) {             /* new net? */
  1236.                 wrtuRec( &ln, of );
  1237.                 last = ln;           /* set new last-written */
  1238.                 }                                /* new net? */
  1239.             if ( last.a.z != Nod.a.z || last.a.n != Nod.a.n ||
  1240.                  last.a.f != Nod.a.f )
  1241.                 wrtuRec( &Nod, of );
  1242.             last = Nod;                  /* set new last-written */
  1243.             break;                   /* fall thru to point-check */
  1244. default:        continue;                               /* next node */
  1245.             }
  1246. /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  1247.         for ( p = pts; p != NULL; p = p->nx ) {
  1248.             if ( p->a.z == Nod.a.z && p->a.n == Nod.a.n &&
  1249.             p->a.f == Nod.a.f ) {
  1250.                 wrtuRec( p, of );
  1251.                 p->prcd = Yes;
  1252.                 ptsleft --;
  1253.                 }                    /* if pts[i].a == Nod.a */
  1254.             }                              /* for i (all points) */
  1255.         }                            /* while nodelist not exhausted */
  1256.     fputs( "\r                        \r", stdout );
  1257.     }
  1258. /* ========================================================================= */
  1259. void    copyProlog( FILE * of, Byte * name, Byte * term )
  1260. {
  1261.     FILE *    fp;
  1262. #if    defined( BIGBUF )
  1263.     char *    filbuf;
  1264. #endif
  1265.     Byte    c;
  1266.  
  1267.     fp = fopen( name, O_RT );
  1268.     if ( fp != NULL ) {
  1269. #if    defined( BIGBUF )
  1270.         filbuf = malloc( FBUFSIZ );
  1271.         if ( filbuf == NULL )
  1272.             printf( "WARNING: no core for file buffer in readCfg()\n" );
  1273.         else    setvbuf( fp, filbuf, _IOFBF, FBUFSIZ );
  1274. #endif
  1275.         c = (Byte) getc( fp );
  1276.         while ( ( ! ferror( fp ) ) && ( ! feof( fp ) ) ) {
  1277.             if ( c == '\n' )
  1278.                 fputs( term, of );
  1279.             else    putc( c, of );
  1280.             c = (Byte) getc( fp );
  1281.             }
  1282.         fclose( fp );
  1283. #if    defined( BIGBUF )
  1284.         if ( filbuf != NULL )
  1285.             free( filbuf );
  1286.         filbuf = NULL;
  1287. #endif
  1288.         }
  1289.     }
  1290. /* ========================================================================= */
  1291. void    readInfd199b( void )
  1292. {
  1293.     FILE *    fp;
  1294. #if    defined( BIGBUF )
  1295.     char *    filbuf;
  1296. #endif
  1297.     static    tNod    Nod;
  1298.     static    Byte    Buf[256];
  1299.  
  1300.     fp = fopen( Cfg.bFile, O_RT );
  1301.     if ( fp == NULL ) {
  1302.         printf( "Can't open %s\n", Cfg.bFile );
  1303.         exit( 2 );
  1304.         }
  1305. #if    defined( BIGBUF )
  1306.     filbuf = malloc( FBUFSIZ );
  1307.     if ( filbuf == NULL )
  1308.         printf( "WARNING: no core for file buffer in readCfg()\n" );
  1309.     else    setvbuf( fp, filbuf, _IOFBF, FBUFSIZ );
  1310. #endif
  1311.     inFd199b = Yes;                      /* notify parseRec() re. Fd199b */
  1312.     parseRec( NULL, NULL, 1 );         /* reset parseRec() state machine */
  1313.     while ( getLine( Buf, fp, 0 ) == Buf ) {
  1314.         parseRec( Buf, &Nod, 0 );
  1315.         if ( Nod.Type != Point )
  1316.             continue;
  1317.         addNod( 1, &Nod );
  1318.         maxpt ++;
  1319.         }
  1320.     inFd199b = No;                                   /* reset parseRec() */
  1321.     fclose( fp );
  1322. #if    defined( BIGBUF )
  1323.     if ( filbuf != NULL )
  1324.         free( filbuf );
  1325.     filbuf = NULL;
  1326. #endif
  1327.     }
  1328. /* ========================================================================= */
  1329. int    main( int argc, Byte * argv[] )
  1330. {
  1331.     FILE *    fp, * of;
  1332. #if    defined( BIGBUF )
  1333.     char *    filbuf1, * filbuf2;
  1334. #endif
  1335.     tNod *    p;
  1336.     long    nBytes;
  1337.     static    tNod    Nod;
  1338.     static    Byte    cfgName[80];
  1339. #if    ! defined( AMIGA )
  1340.     union    REGS    regs;
  1341. #endif                                                              /* AMIGA */
  1342. /* ------------------------------------------------------------------------- */
  1343.     printf( "%s: Militantly Public Domain.\n", VER );
  1344.     strcpy( cfgName, CFGNAME );
  1345.     if ( argc > 1 ) strcpy( cfgName, argv[1] );
  1346.     readCfg( cfgName );                               /* get config info */
  1347.     printf( "FYI: config record is %u bytes long, one node entry uses %u bytes.\n",
  1348.     sizeof( tCfg ), sizeof( tNod ) );
  1349. #if    defined( AMIGA )
  1350.     nBytes = (long) AvailMem( MEMF_LARGEST );
  1351. #else                                                               /* AMIGA */
  1352.     regs.x.bx = 0xffff; regs.h.ah = 0x48;
  1353.     intdos( ®s, ®s );
  1354.     if ( ! regs.x.cflag ) {
  1355.         puts( "damn. a mem alloc which should have failed is OK." );
  1356.         puts( "i guess i'll just give up ... please report this error." );
  1357.         return 10;
  1358.         }
  1359.     nBytes = ( (long) regs.x.bx ) * 16L;
  1360. #endif                                                              /* AMIGA */
  1361.     printf( "     you have some %lu bytes available for points (abt. %luK). this\n", nBytes, nBytes / 1024L );
  1362.     printf( "     setup will handle about %lu point entries and accepts %u valid\n", nBytes / (long) sizeof( tNod ), MAXCMD );
  1363.     printf( "     config commands. %u \042map\042 statements were found, and memory\n", Cfg.maxmap );
  1364.     printf( "     for %u was allocated.\n", MAXMAP );
  1365.     fflush( stdout );
  1366. /* ------------------------------------------------------------------------- */
  1367.     pts = NULL;
  1368. /* ------------------------------------------------------------------------- */
  1369.     memset( &Nod, EOS, sizeof( Nod ) );
  1370.     if ( Cfg.havePointnet == Yes )
  1371.         readPointnet();
  1372.     killNets();
  1373.     mapNets();
  1374.     if ( Cfg.haveInfd199b == Yes )
  1375.         readInfd199b();
  1376.     if ( Cfg.haveUserlist == Yes )
  1377.         readUserlist();
  1378.     for ( p = pts; p != NULL; p = p->nx )
  1379.         p->a.z = Cfg.myZone;
  1380.     if ( maxpt == 0 ) {
  1381.         puts( "\nNothing left to process -- aborted." );
  1382.         exit( 0 );
  1383.         }
  1384.     if ( maxpt > 1 ) {
  1385.         tNod **    pp;
  1386.         tNod **    i;
  1387.         pp = malloc( ( maxpt + 1 ) * sizeof( tNod * ) );
  1388.         if ( pp == NULL ) {
  1389.             puts( "\nshit, everything looked so good and then i didn't have enough" );
  1390.             puts( "memory for the goddam sort ... what a mess!" );
  1391.             exit( 99 );
  1392.             }
  1393.         for ( p = pts, i = pp; p != NULL; p = p->nx, i ++ )
  1394.             *i = p;
  1395.         qsort( (char *) &pp[0], maxpt, sizeof( tNod * ), ptCmp );
  1396.         pts = pp[0];
  1397.         pp[maxpt] = NULL;
  1398.         for ( i = &pp[0]; i < &pp[maxpt]; i ++ )
  1399.             ( *i )->nx = *( i + 1 );
  1400.         free( pp );
  1401.         }
  1402.     removeNets();
  1403.     printf( "the actual number of points being processed is %u.\n", maxpt );
  1404. /* ------------------------------------------------------------------------- */
  1405.     if ( Cfg.Oldnet == Yes ) {
  1406.         printf( "Generating FD 1.99 private list %s\n", Cfg.oFile );
  1407.         of = fopen( Cfg.oFile, O_WB );
  1408.         if ( of == NULL ) {
  1409.             printf( "Yuck: can't create %s\n", Cfg.oFile );
  1410.             exit( 2 );
  1411.             }
  1412. #if    defined( BIGBUF )
  1413.         filbuf2 = malloc( FBUFSIZ );
  1414.         if ( filbuf2 == NULL )
  1415.             printf( "WARNING: no core for file buffer in readCfg()\n" );
  1416.         else    setvbuf( of, filbuf2, _IOFBF, FBUFSIZ );
  1417. #endif
  1418.         fprintf( of, HDR, "oldnet", VER, Cfg.termOldnet );
  1419.         if ( Cfg.haveProlog == Yes )
  1420.             copyProlog( of, Cfg.pFile, Cfg.termOldnet );
  1421.         fp = fopen( Cfg.nFile, O_RT );
  1422.         if ( fp == NULL ) {
  1423.             printf( "Yuck: can't open %s\n", Cfg.nFile );
  1424.             exit( 2 );
  1425.             }
  1426. #if    defined( BIGBUF )
  1427.         filbuf1 = malloc( FBUFSIZ );
  1428.         if ( filbuf1 == NULL )
  1429.             printf( "WARNING: no core for file buffer in readCfg()\n" );
  1430.         else    setvbuf( fp, filbuf1, _IOFBF, FBUFSIZ );
  1431. #endif
  1432.         wrtList( fp, of );
  1433.         fclose( fp );
  1434. #if    defined( BIGBUF )
  1435.         if ( filbuf1 != NULL )
  1436.             free( filbuf1 );
  1437.         filbuf1 = NULL;
  1438. #endif
  1439.         if ( Cfg.haveEpilog == Yes )
  1440.             copyProlog( of, Cfg.eFile, Cfg.termOldnet );
  1441.         fclose( of );
  1442. #if    defined( BIGBUF )
  1443.         if ( filbuf2 != NULL )
  1444.             free( filbuf2 );
  1445.         filbuf2 = NULL;
  1446. #endif
  1447.         }
  1448. /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  1449.     if ( Cfg.haveUserout == Yes ) {
  1450.         printf( "Generating FIDOUSER.LST-style list %s\n", Cfg.tFile );
  1451.         of = fopen( Cfg.tFile, O_WB );
  1452.         if ( of == NULL ) {
  1453.             printf( "Yuck: can't create %s\n", Cfg.tFile );
  1454.             exit( 2 );
  1455.             }
  1456. #if    defined( BIGBUF )
  1457.         filbuf2 = malloc( FBUFSIZ );
  1458.         if ( filbuf2 == NULL )
  1459.             printf( "WARNING: no core for file buffer in readCfg()\n" );
  1460.         else    setvbuf( of, filbuf2, _IOFBF, FBUFSIZ );
  1461. #endif
  1462.         fp = fopen( Cfg.nFile, O_RT );
  1463.         if ( fp == NULL ) {
  1464.             printf( "Yuck: can't open %s\n", Cfg.nFile );
  1465.             exit( 2 );
  1466.             }
  1467. #if    defined( BIGBUF )
  1468.         filbuf1 = malloc( FBUFSIZ );
  1469.         if ( filbuf1 == NULL )
  1470.             printf( "WARNING: no core for file buffer in readCfg()\n" );
  1471.         else    setvbuf( fp, filbuf1, _IOFBF, FBUFSIZ );
  1472. #endif
  1473.         wrtuList( fp, of );
  1474.         fclose( of );
  1475. #if    defined( BIGBUF )
  1476.         if ( filbuf2 != NULL )
  1477.             free( filbuf2 );
  1478.         filbuf2 = NULL;
  1479. #endif
  1480.         fclose( fp );
  1481. #if    defined( BIGBUF )
  1482.         if ( filbuf1 != NULL )
  1483.             free( filbuf1 );
  1484.         filbuf1 = NULL;
  1485. #endif
  1486.         }
  1487. /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  1488.     if ( Cfg.Fd199b == Yes ) {
  1489.         printf( "Generating FD 1.99c point list %s\n", Cfg.fFile );
  1490.         of = fopen( Cfg.fFile, O_WB );
  1491.         if ( of == NULL ) {
  1492.             printf( "Yuck: can't create %s\n", Cfg.fFile );
  1493.             exit( 2 );
  1494.             }
  1495. #if    defined( BIGBUF )
  1496.         filbuf2 = malloc( FBUFSIZ );
  1497.         if ( filbuf2 == NULL )
  1498.             printf( "WARNING: no core for file buffer in readCfg()\n" );
  1499.         else    setvbuf( of, filbuf2, _IOFBF, FBUFSIZ );
  1500. #endif
  1501.         fprintf( of, HDR, "fd199b", VER, Cfg.termFd199b );
  1502.         if ( Cfg.haveProlog == Yes )
  1503.             copyProlog( of, Cfg.pFile, Cfg.termFd199b );
  1504.         wrt199bList( of );
  1505.         if ( Cfg.haveEpilog == Yes )
  1506.             copyProlog( of, Cfg.eFile, Cfg.termFd199b );
  1507.         fclose( of );
  1508. #if    defined( BIGBUF )
  1509.         if ( filbuf2 != NULL )
  1510.             free( filbuf2 );
  1511.         filbuf2 = NULL;
  1512. #endif
  1513.         }
  1514. /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  1515.     if ( Cfg.Clist == Yes ) {
  1516.         printf( "Generating CLIST point list %s\n", Cfg.cFile );
  1517.         of = fopen( Cfg.cFile, O_WB );
  1518.         if ( of == NULL ) {
  1519.             printf( "Yuck: can't create %s\n", Cfg.cFile );
  1520.             exit( 2 );
  1521.             }
  1522. #if    defined( BIGBUF )
  1523.         filbuf2 = malloc( FBUFSIZ );
  1524.         if ( filbuf2 == NULL )
  1525.             printf( "WARNING: no core for file buffer in readCfg()\n" );
  1526.         else    setvbuf( of, filbuf2, _IOFBF, FBUFSIZ );
  1527. #endif
  1528.         fprintf( of, HDR, "clist", VER, Cfg.termClist );
  1529.         if ( Cfg.haveProlog == Yes )
  1530.             copyProlog( of, Cfg.pFile, Cfg.termClist );
  1531.         wrtClist( of );
  1532.         if ( Cfg.haveEpilog == Yes )
  1533.             copyProlog( of, Cfg.eFile, Cfg.termClist );
  1534.         fclose( of );
  1535. #if    defined( BIGBUF )
  1536.         if ( filbuf2 != NULL )
  1537.             free( filbuf2 );
  1538.         filbuf2 = NULL;
  1539. #endif
  1540.         }
  1541. /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  1542.     for ( p = pts; p != NULL; p = p->nx )
  1543.         if ( p->prcd == Yes )
  1544.             p->a.z = p->a.n = p->a.f = p->a.p = 0;
  1545.     removeNets();                                /* clear written points */
  1546.     if ( maxpt > 0 ) {
  1547.         puts( "The following systems were not written due to the lack of a bossnode" );
  1548.         puts( "entry in the specified nodelist:" );
  1549.         dumpList();
  1550.         }
  1551.     else puts( "Input exhausted -- finished." );
  1552. /* ------------------------------------------------------------------------- */
  1553.     unlink( Cfg.lFile );
  1554.     if ( Cfg.haveUserout == Yes ) {
  1555.         static    Byte    t[128], *p;
  1556.         static    Byte *    args[MAXARGS];
  1557.         int    i;
  1558.         while ( ( p = strstr( Cfg.Sort, "{in}" ) ) != NULL ) {
  1559.             memcpy( t, Cfg.Sort, p - Cfg.Sort );
  1560.             t[p - Cfg.Sort] = EOS;
  1561.             strcat( t, Cfg.tFile );
  1562.             strcat( t, p + 4 );                 /* len of "{in}" */
  1563.             strcpy( Cfg.Sort, t );    /* for next pass thru loop */
  1564.             }
  1565.         while ( ( p = strstr( Cfg.Sort, "{out}" ) ) != NULL ) {
  1566.             memcpy( t, Cfg.Sort, p - Cfg.Sort );
  1567.             t[p - Cfg.Sort] = EOS;
  1568.             strcat( t, Cfg.lFile );
  1569.             strcat( t, p + 5 );                /* len of "{out}" */
  1570.             strcpy( Cfg.Sort, t );    /* for next pass thru loop */
  1571.             }
  1572.         printf( "Executing: %s\n", Cfg.Sort );
  1573. #if    defined( AMIGA )
  1574.         i = ! Execute( Cfg.Sort, NULL, NULL );
  1575. /*        {
  1576.             struct    ProcID    pid;
  1577.             if ( ( i = forkv( args[0], args, NULL, &pid ) ) != -1 )
  1578.                 i = wait( &pid );
  1579.             }
  1580. */
  1581. #else                                                               /* AMIGA */
  1582.         p = strtok( Cfg.Sort, " " );
  1583.         i = 0;
  1584.         while ( p != NULL ) {
  1585.             if ( i >= MAXARGS - 1 ) {
  1586.                 printf( "sorry, but your sort command has more than %u tokens.\n", MAXARGS );
  1587.                 unlink( Cfg.tFile );
  1588.                 exit( 2 );
  1589.                 }
  1590.             args[i ++] = p;
  1591.             p = strtok( NULL, " " );
  1592.             }
  1593.         args[i] = NULL;
  1594.         i = spawnvp( P_WAIT, args[0], args );
  1595. #endif                                                              /* AMIGA */
  1596.         if ( i == -1 ) {
  1597.             perror( "main/execsort" );
  1598.             unlink( Cfg.tFile );
  1599.             exit( 2 );
  1600.             }
  1601.         else if ( i )
  1602.             printf( "Warning: %s returned %u\n", args[0], i );
  1603.         fp = fopen( Cfg.lFile, O_RT );
  1604.         if ( fp == NULL ) {
  1605.             printf( "error: sort did not generate %s\n", Cfg.lFile );
  1606.             exit( 2 );
  1607.             }
  1608.         fclose( fp );
  1609.         unlink( Cfg.tFile );
  1610.         }
  1611. /* ------------------------------------------------------------------------- */
  1612.     if ( Cfg.havePointnet == Yes && Cfg.killInput == Yes )
  1613.         if ( unlink( Cfg.iFile ) != 0 ) {
  1614.             printf( "main: can't unlink %s\n", Cfg.iFile );
  1615.             return 1;
  1616.             }
  1617.     if ( Cfg.haveUserlist == Yes && Cfg.killUserlist == Yes )
  1618.         if ( unlink( Cfg.uFile ) != 0 ) {
  1619.             printf( "main: can't unlink %s\n", Cfg.uFile );
  1620.             return 1;
  1621.             }
  1622.     if ( Cfg.haveInfd199b == Yes && Cfg.killInfd199b == Yes )
  1623.         if ( unlink( Cfg.bFile ) != 0 ) {
  1624.             printf( "main: can't unlink %s\n", Cfg.bFile );
  1625.             return 1;
  1626.             }
  1627.     return 0;
  1628.     }
  1629. /* ========================================================================= */
  1630.